/**
 * 
 */
package com.cmpanyandi.elearning.utils;

/**
 * String utils class.
 * @author wojtek
 *
 */
public final class StringUtils {

    /**
     * This method check String content. 
     * @param str - string to check
     * @return true if string is not null and isn't empty.
     */
    public static boolean isNotEmpty(String str) {
	
	return str != null && str.trim().length() > 0 ? true : false;
    }
    
    /**
     * This method return String value from provided chars characters.
     * @param chars - CharSequence
     * @return String if charSequence is not null
     */
    public static String getString(CharSequence chars) {

	return chars != null  ? String.valueOf(chars) : null;
    }
    
    
    /**
     * This method substring string before last substring.
     * @param text - string to extract. 
     * @param ending - ending.
     * @return - extracted string.
     */
    public static String substringBeforeLast(String text, String ending) {
	
	int lastPosition = text.lastIndexOf(ending);
	return lastPosition > 0 ? text.substring(0, lastPosition) : text;
    }
}
